package avicit.bdp.dms.das.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import avicit.platform6.core.properties.PlatformConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;

/**
 * 字段类型
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @修改记录：
 */
@ApiModel(value = "ColumnTypeDTO", description = "bdp_das_column_type")
@Table(name = "bdp_das_column_type")
public class ColumnTypeDTO extends BaseDTO {
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @Id
    @LogField
    @ApiModelProperty(value = "id", name = "id")
    @FieldRemark(column = "id", field = "id", name = "主键")
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

    /**
     * 数据库类型
     */
    @LogField
    @ApiModelProperty(value = "数据库类型", name = "type")
    @FieldRemark(column = "type", field = "type", name = "数据库类型")
    @Column(name = "type")
    private String type;

    /**
     * 类型名称
     */
    @LogField
    @ApiModelProperty(value = "类型名称", name = "name")
    @FieldRemark(column = "name", field = "name", name = "类型名称")
    @Column(name = "name")
    private String name;

    /**
     * 排序
     */
    @LogField
    @ApiModelProperty(value = "排序", name = "orderBy")
    @FieldRemark(column = "order_by", field = "orderBy", name = "排序")
    @Column(name = "order_by")
    private Integer orderBy;

    /**
     * 长度最大值
     */
    @LogField
    @ApiModelProperty(value = "长度最大值", name = "length")
    @FieldRemark(column = "length", field = "length", name = "长度最大值")
    @Column(name = "length")
    private Integer length;

    /**
     * 长度默认值
     */
    @LogField
    @ApiModelProperty(value = "长度默认值", name = "lengthDefault")
    @FieldRemark(column = "length_default", field = "lengthDefault", name = "长度默认值")
    @Column(name = "length_default")
    private Integer lengthDefault;

    /**
     * 精度最大值
     */
    @LogField
    @ApiModelProperty(value = "长度最大值", name = "precisionMax")
    @FieldRemark(column = "precision_max", field = "precisionMax", name = "精度最大值")
    @Column(name = "precision_max")
    private Integer precisionMax;

    /**
     * 是否使用长度：0--不使用，1--使用
     */
    @LogField
    @ApiModelProperty(value = "是否使用长度", name = "lengthUsed")
    @FieldRemark(column = "length_used", field = "lengthUsed", name = "是否使用长度")
    @Column(name = "length_used")
    private Integer lengthUsed;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(Integer orderBy) {
        this.orderBy = orderBy;
    }

    public Integer getLength() {
        return length;
    }

    public void setLength(Integer length) {
        this.length = length;
    }

    public Integer getLengthUsed() {
        return lengthUsed;
    }

    public void setLengthUsed(Integer lengthUsed) {
        this.lengthUsed = lengthUsed;
    }

    public Integer getPrecisionMax() {
        return precisionMax;
    }

    public void setPrecisionMax(Integer precisionMax) {
        this.precisionMax = precisionMax;
    }

    public Integer getLengthDefault() {
        return lengthDefault;
    }

    public void setLengthDefault(Integer lengthDefault) {
        this.lengthDefault = lengthDefault;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "bdp_das_column_type";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "bdp_das_column_type";
        } else {
            return super.logTitle;
        }
    }

    public PlatformConstant.LogType getLogType() {
        if (super.logType == null) {
            return PlatformConstant.LogType.module_operate;
        } else {
            return super.logType;
        }
    }

}
